# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=animatch
pkgver=1.0.2
pkgrel=0
_commit_libsuperderpy="b592a3382fd5d3efc88a0df29031e267f6497910"
arch="all"
url="https://gitlab.com/HolyPangolin/animatch"
pkgdesc="Animatch is a match-three game with cute animals"
license="GPL-3.0-or-later"
makedepends="cmake ninja allegro-dev mesa-dev"
source="https://gitlab.com/HolyPangolin/animatch/-/archive/v$pkgver/animatch-v$pkgver.tar.gz
	libsuperderpy-$_commit_libsuperderpy.tar.gz::https://gitlab.com/dosowisko.net/libsuperderpy/-/archive/$_commit_libsuperderpy.tar.gz"
subpackages="$pkgname-static $pkgname-doc"
options="!check" # No tests
builddir="$srcdir/$pkgname-v$pkgver"

prepare() {
	default_prepare

	# libsuperderpy doesn't have a stable ABI yet so build it statically to prevent conflicts with other packages using it
	rmdir "$builddir"/libsuperderpy
	mv "$srcdir"/libsuperderpy-$_commit_libsuperderpy "$builddir"/libsuperderpy
}

build() {
	cmake -B "$builddir"/build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=OFF \
		-DLIBSUPERDERPY_IMGUI=OFF \
		-GNinja
	ninja -C build
}

check() {
	cd "$builddir"/build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" ninja -C build install
}

sha512sums="6eb052e4aabf43032fb229757f65ed01739a3ecad2037e354d14dbeb0f5e1c88ec00054b9976b91309b0ddc7efcd684f2f97f50ddb7d15c740058a47015310df  animatch-v1.0.2.tar.gz
6fb917ebdd563f26475627ecd8f53d1fb59edb0a56965dff824178e41cbd53f8ea746289e491bddcd5cfbc091a047b4ca084af7a359e2aac4ae9c80093392071  libsuperderpy-b592a3382fd5d3efc88a0df29031e267f6497910.tar.gz"
